package exception;
/*
throw关键字,用于将一个异常抛出
 */
public class ThrowDemo {
    public static void main(String[] args) {
        Person p = new Person();
        try{
            p.setAge(1000);
        }catch(IllegalAgeException e){
            //e.printStackTrace();//向控制台输出异常的堆栈跟踪信息
            System.out.println(e.getMessage());//输出错误信息
        }
        System.out.println("此人年龄:"+p.getAge());
    }
}
